package oop.core.area;
import oop.core.entity.Entity;
import oop.core.map.Location;

/**
 * This is the AreaEffect for Teleporting an Entity
 */
public class TeleportAreaEffect extends AreaEffect {
	
	private String mapName;
	private Location loc;
	
	public String getMapName() {
		return mapName;
	}
	
	/**
	 * @param isOn If the AreaEffect is active
	 * @param delay How long between each time the AreaEffect takes effect
	 * @param mapName The map that will be changed to
	 * @param loc The location on the map that the ent will be put ontox
	 */
	public TeleportAreaEffect(boolean isOn, long delay, String mapName,
			Location loc) {
		super(isOn, delay);
		this.mapName = mapName;
		this.loc = loc;
	}

	/**
	 * Changes the entity's location
	 * @param ent The entity being affected by the areaEffect
	 * @return Returns if the effect happened (based on isOn)
	 */
	public boolean doEffect(Entity ent)
	{
		if(isOn){
			ent.setLocation(loc);
			isOn = false;
			return true;
		} else
		{
			return false;
		}
	}
}